#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

long sum(long n) {
    long sum = 0;
    for (long i = 1; i < n; i++) {
        if (n % i == 0) {
            sum += i;
        }
    }
    return sum;
}

int main() {
    int M;
    scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        long A, B;
        scanf("%ld %ld", &A, &B);
        long sum_A = sum(A);
        long sum_B = sum(B);
        if (sum_A == B && sum_B == A) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
    return 0;
}
